Qwen 3.5 MoE: Add --backend metal export path#18880
Open
manuelcandales wants to merge 4 commits intogh/manuelcandales/174/headfrom
Open
Qwen 3.5 MoE: Add --backend metal export path#18880manuelcandales wants to merge 4 commits intogh/manuelcandales/174/headfrom
manuelcandales wants to merge 4 commits intogh/manuelcandales/174/headfrom
Conversation
Contributor
Author
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18880
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 Cancelled JobsAs of commit f8ff857 with merge base 5707e2a ( CANCELLED JOBS - The following jobs were cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Apr 14, 2026
metascroy
reviewed
Apr 16, 2026
| quantize_experts_metal(model, config, args.qlinear_group_size) | ||
|
|
||
| # Untie lm_head/embedding for independent quantization | ||
| if model.lm_head.weight.data_ptr() == model.embed_tokens.weight.data_ptr(): |
Contributor
There was a problem hiding this comment.
Does the model have tied embeddings?
Contributor
Author
There was a problem hiding this comment.
It seems that tie_word_embeddings defaults to False. I verified that I didn't need this, and just cleaned it up.
metascroy
reviewed
Apr 16, 2026
| if args.qlinear: | ||
| import torchao.experimental.ops.mps # noqa: F401 | ||
| from torchao.experimental.quant_api import UIntxWeightOnlyConfig | ||
| from torchao.quantization.quant_api import quantize_ |
Contributor
There was a problem hiding this comment.
Why can this path not use quantize_model_?
Contributor
Author
There was a problem hiding this comment.
Good catch. Simplified the code here using quantize_model_. This required updating quantize.py with the compatible shape check for the Metal backend quantization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Metal backend support to export.py via --backend metal flag:
experts to MLX affine INT4, quantizes non-expert layers with fpa4w
(skips shared_expert_gate with N<4 for prefill compatibility)
MetalPartitioner
CUDA and MLX paths are unchanged.
Authored with Claude.